<?php /* Smarty version Smarty-3.1.15, created on 2018-11-20 17:48:31
         compiled from "D:\project\classic_games\view\admin\games\main.php" */ ?>
<?php /*%%SmartyHeaderCode:51695bf3d86f608e63-82460125%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'faf5fd2f0efa0202c9967db5222602799819242d' => 
    array (
      0 => 'D:\\project\\classic_games\\view\\admin\\games\\main.php',
      1 => 1542073848,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '51695bf3d86f608e63-82460125',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'CSSDIR' => 0,
    'base_url' => 0,
    'xiaochengxu_editor' => 0,
    'game_info' => 0,
    'v' => 0,
    'total_count' => 0,
    'page' => 0,
    'total_page' => 0,
    'page_url' => 0,
    'page_nums' => 0,
    'JSDIR' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.15',
  'unifunc' => 'content_5bf3d86f71e373_70818420',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_5bf3d86f71e373_70818420')) {function content_5bf3d86f71e373_70818420($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ('../common_admin/left_bar.php', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>

<link href="<?php echo $_smarty_tpl->tpl_vars['CSSDIR']->value;?>
/emoji.css?cb=<?php echo time();?>
" rel="stylesheet" type="text/css" />
<link href="http://cdn.bootcss.com/jqueryui/1.12.0/jquery-ui.min.css" rel="stylesheet">
<style>
    .file{
        width: 160px;
    }

    table tr{
        height: 15px;
    }

    form table tr td{
        width: 100px;
    }
</style>
<form method="post">
    <div style="padding: 10px;" class="tixian-container" >
        <input type="hidden" name="urls" id="urls" value="<?php echo $_smarty_tpl->tpl_vars['base_url']->value;?>
&a=add_game">
        <input type="hidden" name="id" id="id" value="">
        <table>

            </tr>
            <tr id="news">
                <td>经典游戏名称:</td>
                <td><input type="text" name="gamename"></td>
                <td></td>
                <td style="width: 60px">去玩路径</td>
                <td><input type="text" name="path"></td>
                <td></td>
               
            </tr>
            <tr></tr>
            <tr>
                <td>消耗金币:</td>
                <td><input type="number" name="usedgold"></td>
                <td></td>
                <td>游戏图片</td>
                <td>
                    <input type="text" name="gameimg" value="<?php echo $_smarty_tpl->tpl_vars['xiaochengxu_editor']->value['img_card'];?>
"><br>
                    <input type="file" name="gameimgfile" class="file" onchange="changes(this)" id="gameimgfile">
                </td>
            </tr>
            <tr></tr>
            <tr>
                <td>备注:</td>
                <td>
                    <textarea cols="50" rows="5" name="remark"></textarea>
                </td>
            </tr>
            <tr>

            </tr>
            <tr>
                <td><input type="button" value="新建/修改" class="btn" onclick="news()"></td>
            </tr>
        </table>
    </div>
</form>
<div style="padding: 10px;">
    <table class='table table-striped'>
        <thead>
        <th style="width:100px">游戏ID</th>
       <th style="width:200px">游戏名称</th>
       <th style="width:200px;text-align: center">玩该游戏消耗金币</th>
        <th style="width:200px">游戏图片</th>
        <th style="width: 230px">创建时间</th>
        <th style="width:200px;text-align: center;" colspan="2">操作</th>
        </thead>
        <tbody>
        <!--<?php  $_smarty_tpl->tpl_vars['v'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['v']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['game_info']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['v']->key => $_smarty_tpl->tpl_vars['v']->value) {
$_smarty_tpl->tpl_vars['v']->_loop = true;
?>-->
        <tr style="border-bottom: solid 1px #cccccc;">
           <td><?php echo $_smarty_tpl->tpl_vars['v']->value['id'];?>
</td>
            <td><?php echo $_smarty_tpl->tpl_vars['v']->value['gamename'];?>
</td>
            <td style="text-align: center"><?php echo $_smarty_tpl->tpl_vars['v']->value['usedgold'];?>
</td>
            <td><img src="<?php echo $_smarty_tpl->tpl_vars['v']->value['gameimg'];?>
" alt="" style="width: 100px;height: 100px"></td>
         <td><?php echo date("Y-m-d H:i",$_smarty_tpl->tpl_vars['v']->value['createtime']);?>
</td>
            <td  style="text-align: center"><input type="button" value="修改" class="btn" onclick="editor(<?php echo $_smarty_tpl->tpl_vars['v']->value['id'];?>
)"></td>
        </tr>
        <!--<?php } ?>-->
        </tbody>

    </table>
</div>



<div>
    <div style="padding: 10px; background-color: #f3f3f3;">共 <span style="color: #4E8DE5;"><?php echo $_smarty_tpl->tpl_vars['total_count']->value;?>
</span> 条 <span
            style="margin-left: 10px;">第 <span style="color: #4E8DE5;"><?php echo $_smarty_tpl->tpl_vars['page']->value;?>
</span> 页/共 <span
                style="color: #4E8DE5;"><?php echo $_smarty_tpl->tpl_vars['total_page']->value;?>
</span> 页</span> <a style="margin-left: 10px; color: #4E8DE5;"
                                                                         href="<?php echo $_smarty_tpl->tpl_vars['page_url']->value;?>
&page=1">首页</a> <?php if ($_smarty_tpl->tpl_vars['page']->value==1) {?><span style="margin-left: 10px;">上一页</span><?php } else { ?><a style="margin-left: 10px; color: #4E8DE5;"
                                                                     href="<?php echo $_smarty_tpl->tpl_vars['page_url']->value;?>
&page=<?php echo $_smarty_tpl->tpl_vars['page']->value-1;?>
">上一页</a><?php }?> <?php if ($_smarty_tpl->tpl_vars['page']->value==$_smarty_tpl->tpl_vars['total_page']->value) {?><span style="margin-left: 10px;">下一页</span><?php } else { ?><a
            style="margin-left: 10px; color: #4E8DE5;" href="<?php echo $_smarty_tpl->tpl_vars['page_url']->value;?>
&page=<?php echo $_smarty_tpl->tpl_vars['page']->value+1;?>
">下一页</a><?php }?> <a
            style="margin-left: 10px; color: #4E8DE5;" href="<?php echo $_smarty_tpl->tpl_vars['page_url']->value;?>
&page=<?php echo $_smarty_tpl->tpl_vars['total_page']->value;?>
">尾页</a>
        <span style="margin-left: 10px;">请选择页码：</span>
        <select id="selectPageTop" style="margin-left: 10px" onchange="change_page('top')">
            <option>请选择页码</option>
            <!--  <?php  $_smarty_tpl->tpl_vars['v'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['v']->_loop = false;
 $_smarty_tpl->tpl_vars['k'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['page_nums']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['v']->key => $_smarty_tpl->tpl_vars['v']->value) {
$_smarty_tpl->tpl_vars['v']->_loop = true;
 $_smarty_tpl->tpl_vars['k']->value = $_smarty_tpl->tpl_vars['v']->key;
?> -->
            <option value="<?php echo $_smarty_tpl->tpl_vars['v']->value;?>
" <?php if ($_smarty_tpl->tpl_vars['v']->value==$_smarty_tpl->tpl_vars['page']->value) {?>selected="selected" <?php }?>><?php echo $_smarty_tpl->tpl_vars['v']->value;?>
</option>
            <!--  <?php } ?> -->
        </select>
    </div>
</div>

<script src="http://cdn.bootcss.com/jqueryui/1.12.0/jquery-ui.min.js"></script>
<script src="<?php echo $_smarty_tpl->tpl_vars['JSDIR']->value;?>
/evol-colorpicker.min.js" type="text/javascript"></script>
<script>window.jQuery || document.write('<script src="<?php echo $_smarty_tpl->tpl_vars['JSDIR']->value;?>
/jquery-1.11.0.min.js"><\/script>')</script>
<script type="text/javascript">

    function news() {
        gamename = $.trim($(":input[name='gamename']").val());
         path = $.trim($(":input[name='path']").val());
        usedgold = $.trim($(":input[name='usedgold']").val());
        gameimg = $.trim($(":input[name='gameimg']").val());
        remark = $.trim($(":input[name='remark']").val());
        if (gamename.length == 0 || path.length == 0 || usedgold.length == 0 || gameimg.length == 0 || remark.length == 0) {
            alert("输入框不能为空");
            return;
        }
        urls=$("#urls").val();
        id=$("#id").val();
        if(id!=0 && id.length>0){
            $.ajax({
                url: urls,
                data: {
                    'id':id,
                    'gamename': gamename,
                    'path': path,
                    'usedgold': usedgold,
                    'gameimg': gameimg,
                    'remark': remark
                },
                type: 'post',
                dataType: 'json',

                success: function (data) {},

                error: function (data) {}
            });
        }else{
            $.ajax({
                url: urls,
                data: {
                    'gamename': gamename,
                    'path': path,
                    'usedgold': usedgold,
                    'gameimg': gameimg,
                    'remark': remark
                },
                type: 'post',
                dataType: 'json',


                success: function (data) {},

                error: function (data) {}
            });
        }


        gameimgfile=$("#gameimgfile").val();
        if(gameimgfile.length>0){
            var gameimgfile=new FormData();
            var gameimgObj=document.getElementById("gameimgfile").files[0];
            gameimgfile.append("file",gameimgObj);
            var xhr = new XMLHttpRequest();
            var FileController=urls;
            xhr.open("post", FileController, true);
            xhr.send(gameimgfile);
        }
        alert('操作成功');
        location.href = "<?php echo $_smarty_tpl->tpl_vars['base_url']->value;?>
&a=main";
    }

    function  changes(obj){
        fileurl=$(obj).val();
        $(":input[name='gameimg']").val(fileurl);
    }

    function editor(obj) {
        $(":input[name='channel']").attr('readonly',"true");
        $(":input[name='urls']").val("<?php echo $_smarty_tpl->tpl_vars['base_url']->value;?>
&a=editor");
        id=obj;
        $(":input[name='id']").val(id);
        $.ajax({
            url: "<?php echo $_smarty_tpl->tpl_vars['base_url']->value;?>
&a=find",
            data: {
                'id':id
            },
            type: 'post',
            dataType: 'json',

            success: function (data) {
                result=data.result;
                $(":input[name='gamename']").val(result.gamename);
                $(":input[name='path']").val(result.path);
                $(":input[name='usedgold']").val(result.usedgold);
                $(":input[name='gameimg']").val(result.gameimg);
                $(":input[name='remark']").val(result.remark);

            },

            error: function (data) {}
        });
    }

    function change_page(pos) {
        var objS;
        if ('top' == pos) {
            objS = document.getElementById("selectPageTop");
        } else if ('bot' == pos) {
            objS = document.getElementById("selectPageBot");
        }

        var selectedPage = objS.options[objS.selectedIndex].value;
        location.href = "<?php echo $_smarty_tpl->tpl_vars['page_url']->value;?>
&page=" + selectedPage;
    }
</script>
<?php echo $_smarty_tpl->getSubTemplate ('../common_admin/right_bar.php', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
<?php }} ?>
